package com.bjdd.jdy.view.widget;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;

import com.bjdd.jdy.R;
import com.bjdd.jdy.adapter.PopListAdapter;
import com.bjdd.jdy.util.L;
import com.bjdd.jdy.util.PopUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/4/11.
 */

public class PopList extends PopupWindow {
    private Context mContenxt;
    private View view;
    private ListView lv;
    private List<String> mData;
    private AdapterView.OnItemClickListener listener;
    private void close(){
        this.dismiss();
    }
    public PopList(Context context, List<String> data, AdapterView.OnItemClickListener listener){
        this.mContenxt = context;
        this.mData =data;
        this.listener = listener;
//        listener = new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                L.d("click " + mData.get(position));
//                close();
//            }
//        };
        this.view = LayoutInflater.from(mContenxt).inflate(R.layout.list_pop,null);
        lv = (ListView)view.findViewById(R.id.lv_list_pop);
        PopListAdapter adapter = new PopListAdapter(mContenxt,mData);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(this.listener);
        //设置外部可点击
        this.setOutsideTouchable(true);
        this.setContentView(this.view);
        this.setHeight(500);
        this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
//        //设置窗体可点击
//        this.setFocusable(true);
//        //实例化一个ColorDrawable颜色为半透明
//        ColorDrawable dw = new ColorDrawable(0xb0000000);
//        //设置弹出窗体背景
//        this.setBackgroundDrawable(new BitmapDrawable());
//        this.setAnimationStyle(R.style.app_pop);

        this.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss() {
            }
        });
    }
}
